feat(mobile): queue/send from the keyboard Return key (#7, #8) - #16
Conversation
Fixes #8. Closes #7. Mobile queueing already worked end-to-end (every send enqueues to the thread outbox, which sends-when-idle and holds-when-busy; the primary button already relabels to "Queue" while busy and a queueCount indicator exists). The only gap was the keyboard: the soft-keyboard Return inserted a newline, and submit was only wired to hardware Command-Return on iOS (and not at all on Android). - iOS: intercept a bare "\n" in the shouldChangeText delegate and fire onComposerSubmit (soft keyboard or hardware Return). Exact single "\n" only, so a multi-line paste ("a\nb") is unaffected; Command-Return keyCommand intact. - Android: wire onComposerSubmit for the first time — an onComposerSubmit event, plus a plain-Enter interception on both the key-event path (onKeyDown) and the IME commitText path, with Shift+Enter still inserting a newline. Multi-line input type preserved. - RN: forward onSubmit -> onComposerSubmit through the Android wrapper (was dropped); iOS wrapper already forwarded it. - Composer: Return routes to the existing handleSend (queue-when-busy / send-when-idle), so queueCount updates the same way as the button. Add a dedicated "Insert line break" toolbar button (inserts "\n" at the caret via the same replaceTextRange helper used for @file / skill tokens) as the cross-platform newline affordance now that Return submits. - Extract resolveComposerSendLabel as a pure, unit-tested helper. Trade-off: hardware plain-Return now submits instead of inserting a newline (matching desktop Enter=submit); the newline button and Shift+Return cover multiline. Tests: composerSendLabel (Send/Queue matrix) and replaceTextRange newline cases. Native keyboard behavior verified on the iOS Simulator; Android soft-keyboard paths need on-device QA (noted on the PR). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Review follow-up: a bare Return now submits, but Shift+Return was also delivering "\n" through the shouldChangeText delegate and submitting — inconsistent with Android (Shift+Enter inserts a newline) and with this PR's own description. Add a Shift+Return UIKeyCommand that inserts a line break via an `isInsertingHardLineBreak` flag the delegate honors, so hardware Shift+Return matches Android and desktop Shift+Enter. Soft keyboards still use the composer's line-break button. Verified: swiftlint --strict clean; iOS Simulator (iPhone 17 Pro) build succeeds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Verification summaryOpus 5 review → APPROVE (no blockers). Traced every path across Swift/Kotlin/TS; confirmed:
Applied one review follow-up ( Checks
|
Summary
Fixes #8, closes #7. On mobile there was no keyboard way to queue/send a message to a working thread — the soft-keyboard Return inserted a newline, and submit was only wired to hardware ⌘-Return on iOS (and not at all on Android).
Note on #7: its premise is outdated. Queueing already works end-to-end today — every "send" enqueues to the thread outbox (sends-when-idle, holds-when-busy), the primary button already relabels to "Queue" while busy, and a
queueCountindicator already shows pending messages. The only unmet criterion across #7/#8 was the keyboard trigger, which this PR adds — so it closes both.Changes
T3ComposerEditorView.swift): intercept a bare"\n"in theshouldChangeTextdelegate → fireonComposerSubmit(soft keyboard or hardware Return). Exact single"\n"only, so a multi-line paste ("a\nb") is unaffected; the existing ⌘-ReturnkeyCommandis untouched.T3ComposerEditorView.kt/Module.kt): wireonComposerSubmitfor the first time — a new event, plus a plain-Enter interception on both the hardware key-event path (onKeyDown) and the soft-keyboardcommitText("\n")path, with Shift+Enter still inserting a newline.TYPE_TEXT_FLAG_MULTI_LINEpreserved.T3ComposerEditor.native.tsx): forwardonSubmit → onComposerSubmit(previously dropped on Android; iOS already forwarded it).ThreadComposer.tsx): Return routes to the existinghandleSend(queue-when-busy / send-when-idle), soqueueCountupdates identically to the button. Adds a dedicated "Insert line break" toolbar button (inserts"\n"at the caret via the samereplaceTextRangehelper used for @file/skill tokens) as the cross-platform newline affordance now that Return submits.resolveComposerSendLabelas a pure, unit-tested helper.Trade-off (intended): hardware plain-Return now submits instead of inserting a newline (matching desktop Enter=submit). Newline remains available via the toolbar button and Shift+Return.
Testing
composerSendLabel(Send/Queue matrix) andreplaceTextRangenewline cases (caret mid-text, at end, replacing a selection). → all green (57 threads/state + 10 shared).nevererrors are unrelated).lint:mobile): swiftlint--strict0 violations, ktlint + detekt pass.commitTextpaths are designed to be mutually exclusive, but this is IME-dependent), Shift+Enter inserts a newline, and the newline button (controlled-valuesetText) is not caught by thecommitTextinterception.🤖 Generated with Claude Code